
#pragma once
#include "Definitions.h"

#include <stdio.h>
#include <string>
#include <vector>
#include <exception>

namespace ttgLib
{
	//Basic Error.
	class Error :public std::exception
	{
		private:
			std::string _message;					//"Achtung!".
			std::vector<std::string> _innerErrors;	//List of inner errors.
		protected:
			//Returns formatted string with error position.
			static std::string FormatErrorPosition(const char *className,
												   const char *methodName)
			{ return std::string(className) + "." + std::string(methodName) + "()"; }
			//Creates Error with given description.
			//Each parameter can be equal to NULL.
			Error(const char *errorName,
						 const char *position,
						 const char *description,
						 Error *innerError);
		public:
			//Returns list with internal errors.
			std::vector<std::string> &GetInnerErrors()
			{ return _innerErrors; }
			//Returns string description of the error.
			virtual const char *ToString() const
			{ return _message.c_str(); }
			//Calls toString() method.
			virtual const char *what() const
			{ return ToString(); }
			//For descendents only.
			virtual ~Error()
			{ /*nothing*/ }
	};
}
